﻿/*****************************************************************//**
 * @file    FITKAcousticsVTKGraphObjectScalarBars.h
 * @brief   Graph object for a series of scalar bars.
 *  
 * @author  ChengHaotian (yeguangbaozi@foxmail.com)
 * @date    2024-11-22
 *********************************************************************/

#ifndef __FITKACOUSTICSVTKGRAPHOBJECTSCALARBARS_H__
#define __FITKACOUSTICSVTKGRAPHOBJECTSCALARBARS_H__

#include "FITKAcousticsVTKGraphObject3D.h"

#include "FITKAcousticsVTKGraphAdaptorAPI.h"

// Forward declaration
class vtkLookupTable;
class vtkScalarBarActor;

namespace Exchange
{
    /**
     * @brief   Graph object for a series of scalar bars.
     * @author  ChengHaotian (yeguangbaozi@foxmail.com)
     * @date    2024-11-22
     */
    class FITKACOUSTICSGRAPHADAPTORAPI FITKAcousticsVTKGraphObjectScalarBars : public FITKAcousticsVTKGraphObject3D
    {
        // Regist
        FITKGraphObjectRegist(FITKAcousticsVTKGraphObjectScalarBars, FITKAcousticsVTKGraphObject3D);
        FITKCLASS(Exchange, FITKAcousticsVTKGraphObjectScalarBars);

    public:
        /**
         * @brief   Constructor.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-22
         */
        FITKAcousticsVTKGraphObjectScalarBars();

        /**
         * @brief   Destructor.[virtual]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-22
         */
        ~FITKAcousticsVTKGraphObjectScalarBars();

        /**
         * @brief   Get the scalar bar with the given port.
         * @param   port: The port of the scalar bar[default]
         * @return  The scalar bar
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-22
         */
        vtkScalarBarActor* getScalarBarByPort(int port = 0);

        /**
         * @brief   Set the scalar bar's information by the given port.
         * @param   title: The title text
         * @param   min: The min range of the bar
         * @param   max: The max range of the bar
         * @param   port: The port of the scalar bar[default]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-22
         */
        void setInfo(QString title, double min, double max, int port = 0);

        /**
         * @brief   Set the bar's visibility.
         * @param   visibility: The visibility of the bar
         * @param   port: The port of the scalar bar[default]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-22
         */
        void setVisibleByPort(bool visibility, int port = 0);

        /**
         * @brief   Set the bars' visibility.[override]
         * @param   visibility: The visibility of the bars
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-22
         */
        void setVisible(bool visibility) override;

        /**
         * @brief   Enable or disbale log scale mode.
         * @param   isOn: Enable or disable
         * @param   port: The port of the scalar bar[default]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-28
         */
        void setEnableLogScale(bool isOn, int port = 0);

    private:
        /**
         * @brief   Create a new scalar bar with the given port.
         * @param   port: The port of the scalar bar[default]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-22
         */
        void createScalarBar(int port = 0);

        /**
         * @brief   Update the scalar bar actor's size and position with the index of the bar.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-22
         */
        void updateScalarBarSizeAndPos();

    private:
        /**
         * @brief   The port for the scalar bars.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-22
         */
        int m_port = 0;

        /**
         * @brief   The port and scalar bar dict.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-22
         */
        QHash<int, vtkScalarBarActor*> m_barHash;

    };
}   // namespace Exchange

#endif // __FITKACOUSTICSVTKGRAPHOBJECTSCALARBARS_H__
